package crp.core.department.domain.services;

import com.qwlabs.panache.Ranged;
import crp.core.department.domain.models.DepartmentEntity;
import crp.core.department.domain.repositories.DepartmentRepository;
import io.quarkus.panache.common.Range;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import java.util.Collection;
import java.util.stream.Stream;

@ApplicationScoped
public class DepartmentSearcher {
    private final DepartmentRepository departmentRepository;

    @Inject
    public DepartmentSearcher(DepartmentRepository departmentRepository) {
        this.departmentRepository = departmentRepository;
    }

    public Ranged<DepartmentEntity> by(Range range) {
        return Ranged.of(departmentRepository.findAll(), range);
    }

    public Stream<DepartmentEntity> byIds(Collection<String> ids) {
        return departmentRepository.findByIds(ids);
    }
}
